﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CE.Job;

public partial class job_details : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Params["jid"] == null)
            {
                Response.Redirect("job-list.aspx");
            }
            else
            {
                int _jobid = int.Parse(Request.Params["jid"].ToString());
                Job _job = new Job();
                JobDB _jobdb = new JobDB();
                _job = _jobdb.GetJobByID(_jobid);
                if (_job != null)
                {
                    if (_job.Status == true)
                    {
                        lblJobTitle.Text = _job.JobTitle;
                        lblJobDescription.Text = _job.JobDescription;
                        lblResponsibilities.Text = _job.Responsibilities;
                        lblRequirements.Text = _job.Requirements;
                        lblCreatedDate.Text = _job.CreatedDate.ToString("dd MMM yyyy");
                        lblEndDate.Text = _job.EndDate.ToString("dd MMM yyyy");
                        lblStartDate.Text = _job.StartDate.ToString("dd MMM yyyy");

                        if (!this.DesignMode)
                        {
                            Page.Title = _job.JobTitle;

                            // Render: <meta name="keywords" content="Some words listed here" />
                            System.Web.UI.HtmlControls.HtmlMeta meta = new System.Web.UI.HtmlControls.HtmlMeta();
                            meta.Name = "keywords";
                            meta.Content = "Some words listed here";
                            this.Header.Controls.Add(meta);
                        }

                        string _country = _job.Country;
                        switch (_country)
                        {
                            case "HK":
                                aHK.Attributes.Add("class", "select");
                                break;
                            case "ID":
                                aID.Attributes.Add("class", "select");
                                break;
                            case "MY":
                                aMY.Attributes.Add("class", "select");
                                break;
                            case "SG":
                                aSG.Attributes.Add("class", "select");
                                break;
                            case "TH":
                                aTH.Attributes.Add("class", "select");
                                break;
                        }
                    }
                    else
                    {
                        Response.Redirect("job-list.aspx");
                    }
                }
                else
                {
                    Response.Redirect("job-list.aspx");
                }
            }

            if (Session[CE.Global.General.UserId] != null)
            {
                liLogin.Visible = false;
                liProfile.Visible = true;
                liApplication.Visible = true;
                liLogout.Visible = true;
                liChangePass.Visible = true;
            }
        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("job-list.aspx");
    }
    protected void btnApply_Click(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] != null)
        {
            Response.Redirect("job-submit.aspx?jid=" + Request.Params["jid"].ToString());
        }
        else
        {
            Response.Redirect("../user/login.aspx?jid=" + Request.Params["jid"].ToString());
        }
    }
}
